package com.scau.vo;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * SaleOrder entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "sale_order", catalog = "db_hairdressingpos")
public class SaleOrder implements java.io.Serializable {

	// Fields

	private Integer id;
	private Employee employee;
	private Vip vip;
	private Admin admin;
	private String saleOrderNo;
	private String customerName;
	private Timestamp saleDateTime;
	private String total;
	private String stuffName;
	private String status;
	private String barberName;
	private Set<SaleOrderItem> saleOrderItems = new HashSet<SaleOrderItem>(0);
	private Set<Payment> payments = new HashSet<Payment>(0);

	// Constructors

	/** default constructor */
	public SaleOrder() {
	}

	/** minimal constructor */
	public SaleOrder(Employee employee, Vip vip, Admin admin,
			String saleOrderNo, Timestamp saleDateTime, String total,
			String status) {
		this.employee = employee;
		this.vip = vip;
		this.admin = admin;
		this.saleOrderNo = saleOrderNo;
		this.saleDateTime = saleDateTime;
		this.total = total;
		this.status = status;
	}

	/** full constructor */
	public SaleOrder(Employee employee, Vip vip, Admin admin,
			String saleOrderNo, String customerName, Timestamp saleDateTime,
			String total, String stuffName, String status, String barberName,
			Set<SaleOrderItem> saleOrderItems, Set<Payment> payments) {
		this.employee = employee;
		this.vip = vip;
		this.admin = admin;
		this.saleOrderNo = saleOrderNo;
		this.customerName = customerName;
		this.saleDateTime = saleDateTime;
		this.total = total;
		this.stuffName = stuffName;
		this.status = status;
		this.barberName = barberName;
		this.saleOrderItems = saleOrderItems;
		this.payments = payments;
	}

	// Property accessors
	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "barber", nullable = false)
	public Employee getEmployee() {
		return this.employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "customerNo", nullable = false)
	public Vip getVip() {
		return this.vip;
	}

	public void setVip(Vip vip) {
		this.vip = vip;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "stuff", nullable = false)
	public Admin getAdmin() {
		return this.admin;
	}

	public void setAdmin(Admin admin) {
		this.admin = admin;
	}

	@Column(name = "saleOrderNo", nullable = false, length = 191)
	public String getSaleOrderNo() {
		return this.saleOrderNo;
	}

	public void setSaleOrderNo(String saleOrderNo) {
		this.saleOrderNo = saleOrderNo;
	}

	@Column(name = "customerName")
	public String getCustomerName() {
		return this.customerName;
	}

	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}

	@Column(name = "saleDateTime", nullable = false, length = 19)
	public Timestamp getSaleDateTime() {
		return this.saleDateTime;
	}

	public void setSaleDateTime(Timestamp saleDateTime) {
		this.saleDateTime = saleDateTime;
	}

	@Column(name = "total", nullable = false)
	public String getTotal() {
		return this.total;
	}

	public void setTotal(String total) {
		this.total = total;
	}

	@Column(name = "stuffName")
	public String getStuffName() {
		return this.stuffName;
	}

	public void setStuffName(String stuffName) {
		this.stuffName = stuffName;
	}

	@Column(name = "status", nullable = false)
	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Column(name = "barberName")
	public String getBarberName() {
		return this.barberName;
	}

	public void setBarberName(String barberName) {
		this.barberName = barberName;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "saleOrder")
	public Set<SaleOrderItem> getSaleOrderItems() {
		return this.saleOrderItems;
	}

	public void setSaleOrderItems(Set<SaleOrderItem> saleOrderItems) {
		this.saleOrderItems = saleOrderItems;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "saleOrder")
	public Set<Payment> getPayments() {
		return this.payments;
	}

	public void setPayments(Set<Payment> payments) {
		this.payments = payments;
	}
	
	@Override
	public String toString() {
		return "{\"id\":" + id 
				+ ", \"employeeName\":" + "\"" + employee.getName() + "\""
				+ ", \"employeeId\":" + employee.getId()
				+ ", \"vipName\":" + "\"" + vip.getName() + "\""
				+ ", \"vipId\":" + vip.getId()
				+ ", \"adminName\":" + "\"" + admin.getName() + "\""
				+ ", \"adminId\":" + admin.getId()
				+ ", \"saleOrderNo\":" + "\"" +saleOrderNo + "\""
				+ ", \"saleDateTime\":" + "\"" + saleDateTime + "\""
				+ ", \"total\":" + "\"" + total + "\""
				+ ", \"status\":" + "\"" +status+ "\""
				+ "}";
	}

}